home *** CD-ROM | disk | FTP | other *** search
/ HPAVC / HPAVC CD-ROM.iso / pc / 3DTOSHI2.ZIP / mpgfx / source / gfxtimer.cpp < prev    next >
Encoding:
C/C++ Source or Header  |  1996-03-25  |  1.8 KB  |  87 lines

  1.  
  2. // gfxtimer.cpp
  3. //
  4. // Copyright (c) 1995 by Toshiaki Tsuji, all rights reserved.
  5.  
  6. #include "stdgfx.h"
  7. #include "gfxtimer.h"
  8.  
  9. MYTIMER::MYTIMER () : DCIClass ()
  10.   {
  11.   } // End of Constructor for MYTIMER
  12.  
  13. MYTIMER::~MYTIMER ()
  14.   {
  15.   } // End of Destructor for MYTIMER
  16.  
  17. BOOLEAN MYTIMER::Init ()
  18.   {
  19.     return SUCCESS;
  20.   } // End of Destructor for MYTIMER
  21.  
  22. VOID MYTIMER::DeInit ()
  23.   {
  24.   } // End of Destructor for MYTIMER
  25.  
  26. VOID MYTIMER::StartTimer ()
  27.   {
  28.     StartClock = clock ();
  29.   } // End of StartTimer for MYTIMER
  30.  
  31. VOID MYTIMER::EndTimer ()
  32.   {
  33.     EndClock = clock ();
  34.   } // End of EndTimer for MYTIMER
  35.  
  36. double MYTIMER::GetFrameRate ( LONG Count )
  37.   {
  38.     #ifndef __FORUNIX__
  39.       double FrameRate;
  40.  
  41.       if (StartClock==EndClock)
  42.         return 0;
  43.  
  44.       FrameRate = (double)Count*CLOCKS_PER_SEC / (double)(EndClock-StartClock);
  45.       return FrameRate;
  46.     #else
  47.       if (Count)
  48.         {}
  49.       return 0;
  50.     #endif 
  51.   } // End of GetFrameRate for MYTIMER
  52.  
  53. VOID MYTIMER::GetDateTime ( DATETIMETYPE *DateTime )
  54.   {
  55.     if (DateTime==NULL)
  56.       return;
  57.         
  58.     #if defined (__FORWATCOM__)
  59.       struct dosdate_t Date;
  60.       struct dostime_t Time;
  61.  
  62.       _dos_getdate ( &Date );
  63.       _dos_gettime ( &Time );
  64.       
  65.       DateTime->Year = Date.year;
  66.       DateTime->Month = Date.month;
  67.       DateTime->Day = Date.day;
  68.       DateTime->Hour = Time.hour;
  69.       DateTime->Minutes = Time.minute;
  70.       
  71.     #elif defined (__FORBORLAND__)
  72.       struct date Date;
  73.       struct time Time;
  74.  
  75.       getdate ( &Date );
  76.       gettime ( &Time );
  77.  
  78.       DateTime->Year = Date.da_year;
  79.       DateTime->Month = Date.da_mon;
  80.       DateTime->Day = Date.da_day;
  81.       DateTime->Hour = Time.ti_hour;
  82.       DateTime->Minutes = Time.ti_min;
  83.     #endif  
  84.   } // End of GetDateTime for MYTIMER
  85.  
  86.  
  87.